package com.ruoyi.web.controller.eamp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.eamp.domain.EampReMan;
import com.ruoyi.eamp.domain.vo.LogAndReAndSrAndDeptVO;
import com.ruoyi.eamp.service.IEampReManService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.eamp.domain.EampReLogs;
import com.ruoyi.eamp.service.IEampReLogsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备全部记录Controller
 *
 * @author ruoyi
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/eamp/re_logs")
public class EampReLogsController extends BaseController
{
    @Autowired
    private IEampReLogsService eampReLogsService;

    @Autowired
    private ISysUserService userService;

    @Autowired
    private IEampReManService eampReManService;
    /**
     * 查询设备全部记录列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:re_logs:list')")
    @GetMapping("/list")
    public TableDataInfo list(EampReLogs eampReLogs)
    {
        startPage();
        List<EampReLogs> list = eampReLogsService.selectEampReLogsList(eampReLogs);
        return getDataTable(list);
    }
    /*
    * 查询VO列表listVO
    * */
    @PreAuthorize("@ss.hasPermi('eamp:re_logs:list')")
    @GetMapping("/listVO")
    public TableDataInfo listVO()
    {
        List<LogAndReAndSrAndDeptVO> list = eampReLogsService.selectEampReLogsListVO();
        return getDataTable(list);
    }
    /*
    * 查询用户列表
    * */
    @GetMapping("/listUser")
    public AjaxResult listUser(){
        SysUser sysUser = new SysUser();
        return success(userService.selectUserList(sysUser));
    }
    /**
    * 查询设备列表listRe
    * */
    @GetMapping("/listRe")
    public AjaxResult listRe(){
        EampReMan eampReMan = new EampReMan();
        return success(eampReManService.selectEampReManList(eampReMan));
    }
    /**
     * 导出设备全部记录列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:re_logs:export')")
    @Log(title = "设备全部记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EampReLogs eampReLogs)
    {
        List<EampReLogs> list = eampReLogsService.selectEampReLogsList(eampReLogs);
        ExcelUtil<EampReLogs> util = new ExcelUtil<EampReLogs>(EampReLogs.class);
        util.exportExcel(response, list, "设备全部记录数据");
    }

    /**
     * 获取设备全部记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('eamp:re_logs:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(eampReLogsService.selectEampReLogsByLogId(logId));
    }

    /**
     * 新增设备全部记录
     */
    @PreAuthorize("@ss.hasPermi('eamp:re_logs:add')")
    @Log(title = "设备全部记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EampReLogs eampReLogs)
    {
        return toAjax(eampReLogsService.insertEampReLogs(eampReLogs));
    }

    /**
     * 修改设备全部记录
     */
    @PreAuthorize("@ss.hasPermi('eamp:re_logs:edit')")
    @Log(title = "设备全部记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EampReLogs eampReLogs)
    {
        return toAjax(eampReLogsService.updateEampReLogs(eampReLogs));
    }

    /**
     * 删除设备全部记录
     */
    @PreAuthorize("@ss.hasPermi('eamp:re_logs:remove')")
    @Log(title = "设备全部记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(eampReLogsService.deleteEampReLogsByLogIds(logIds));
    }
}
